#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std;

int main() {
    int arr[100010] = { 0 };
    long long dp[100010] = { 0 };
    int n, q;
    cin >> n >> q;

    for (int i = 1; i <= n; ++i)
    {
        cin >> arr[i];
        dp[i] = dp[i - 1] + arr[i];
    }

    for (int i = 1; i <= q; ++i)
    {
        int l, r;
        cin >> l >> r;
        cout << dp[r] - dp[l] << std::endl;
    }

}